<!--
    保险信息 公共插件
        参数：对象类型
             Obj: {
                contractNo: 合同号,
                roleType: 角色类型,（枚举类型：经销商:SP ）
            }

-->


<style>
    @import "../../../../styles/common/basic-info.css";
</style>
<template>
    <Form ref="custInsuranceForm" :model="custInsuranceForm" :label-width="100" inline>
        <Row>
            <FormItem label="投保方式">
                <Select v-model="custInsuranceForm.insuranceMode" style="width:160px" disabled
                        placeholder="投保方式">
                    <Option v-for="item in dataDic.insuranceMode" :value="item.value" :label="item.title"
                            :key="item.value">{{ item.title }}
                    </Option>
                </Select>
            </FormItem>
        </Row>
        <FormItem label="商业险保单号" v-show="insuranceMode === 'electronics'">
            <Input type="text" v-model="custInsuranceForm.insuranceNo" disabled/>
        </FormItem>
        <FormItem label="商业险保险公司" v-show="insuranceMode === 'electronics'">
            <Input type="text" v-model="custInsuranceForm.insuranceCompany" disabled/>
        </FormItem>
        <FormItem label="商业险开始日期">
            <DatePicker type="date" v-model="custInsuranceForm.insuranceStartTime" disabled/>
        </FormItem>
        <FormItem label="商业险结束日期">
            <DatePicker type="date" v-model="custInsuranceForm.insuranceEndTime" disabled/>
        </FormItem>
    </Form>
</template>
<script>

    import {getCustInsuranceInfo} from "_p/basic/api/contract/common/cust-insurance/cust-insurance";
    import {getByTypes} from "_p/basic/api/admin/datadic";
    import {deepClone} from '@/libs/utils/ObjectClone';
    import {channelType} from "_p/basic/api/contract/channel-type/channel-type";

    export default {
        props: {
            Obj: {
                roleType: "",
                contractNo: "",
                type: Object
            }
        },
        data() {
            return {
                insuranceMode: null,
                dataDic: {},
                custInsuranceForm: {},
                dicKeys: ["insuranceMode"],
            };
        },
        methods: {
            init() {
                this.getCustInsuranceInfo();
            },
            getCustInsuranceInfo() {
                getCustInsuranceInfo(this.Obj.contractNo, channelType(this.$route.meta.params)).then(res => {
                    if (res.code === "0000") {
                        this.insuranceMode = res.data.insuranceMode;
                        this.custInsuranceForm = deepClone(res.data);
                    } else {
                        this.$Message.error(res.msg);
                    }
                });
            },
            initDataDic() {
                let self = this;
                getByTypes(self.dicKeys).then(res => {
                    if (res.code === "0000" && res.data) {
                        self.dataDic = res.data;
                    }
                });
            }
        },
        mounted() {
            this.initDataDic();
            this.init();
        }
    };
</script>
